package com.japp.manager.web;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.japp.base.BaseAction;
import com.japp.manager.bean.SummaryBean;
import com.japp.manager.service.SummaryService;
import com.japp.sys.service.SelectService;
/**
 * 总结
 * @author Administrator
 *
 */
@Scope("prototype")
@Controller
public class SummaryAction extends BaseAction<SummaryBean> {

	private static final long serialVersionUID = -5677670163048708848L;
	@Autowired
	private SummaryService summaryService;
	@Autowired
	private SelectService selectService;
	private SummaryBean summary = new SummaryBean();
	private Map<String, String> map = null;
	
	/**
	 * 查询总结
	 * @return
	 */
	public String querySummary(){
		String power = session.getAttribute("u_power").toString();
		//String dpid = session.getAttribute("userltd").toString();
		String dpcode = session.getAttribute("userltdcode").toString();
		String usercode = session.getAttribute("u_code").toString();
		//部门
		if("2".equals(power)){
			summary.setS_submit_dpcode(dpcode);
		//业务员
		}else if("3".equals(power)){
			summary.setS_submit_ucode(usercode);
		}
		map = selectService.getSelMapByString("14,13");
		page = summaryService.getPage(page, summary);
		return SUCCESS;
	}
	/**
	 * 查看
	 * @return
	 */
	public String findSummaryView(){
		map = selectService.getSelMapByString("14,13");
		if(summary.getS_id()!=0){
			summary = summaryService.findSummaryById(summary.getS_id());
		}
		return "summaryView";
	}
	/**
	 * 欲新增 以及更新 
	 * @return summaryView summaryDetil
	 */
	public String findSummaryDetil(){
		map = selectService.getSelMapByString("14,13");
		if(summary.getS_id()!=0){
			summary = summaryService.findSummaryById(summary.getS_id());
		}
		return "summaryDetil";
	}
	/**
	 * 删除
	 * @return
	 */
	public void deleteSummaryById(){
		int rel = summaryService.deleteSummary(keys);
		if(rel>0){
			result = "删除成功!";
		}else {
			result = "删除失败!";
		}
		wPrint(result);
	}
	/**
	 * 更新
	 * @return
	 */
	public void updateSummaryById(){
		int rel = summaryService.updateSummary(summary);
		if(rel>0){
			result = String.valueOf(summary.getS_id());
		}else {
			result = "error";
		}
		wPrint(result);
	}
	/**
	 * 新增
	 */
	public void insertSummaryById(){
		int rel = summaryService.insertSummary(summary);
		if(rel>0&&summary.getS_id()!=0){
			result = ""+summary.getS_id();
		}else {
			result = "0";
		}
		wPrint(result);
	}
	public SummaryBean getSummary() {
		return summary;
	}
	public void setSummary(SummaryBean summary) {
		this.summary = summary;
	}
	public Map<String, String> getMap() {
		return map;
	}
	public void setMap(Map<String, String> map) {
		this.map = map;
	}
	
	
}

